package org.agent.aigccore.model.bo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.agent.aigccore.basic.enums.IotWorkOrderStatusEnum;
import org.agent.aigccore.basic.serializable.BaseExtInfoBaseDBModel;
import org.agent.aigccore.basic.serializable.CustomConverter;
import org.agent.aigccore.model.po.IotWorkOrderPO;
import org.agent.aigccore.model.vo.IotWorkOrderVO;
import org.mapstruct.DecoratedWith;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.Date;

/**
 * IoT工单BO类
 */
@Slf4j
@Setter
@Getter
@Schema(description = "IoT工单业务对象")
public class IotWorkOrderBO extends BaseExtInfoBaseDBModel {
    private String name;
    private String type;
    private IotWorkOrderStatusEnum status;
    private String stage;
    private Long businessGroupId;
    private String businessGroupName;
    private Long feedingDeviceId;
    private String feedingDeviceName;
    private Long unloadingDeviceId;
    private String unloadingDeviceName;
    private String data;
    private String outBizId;
    private String outBizData;
    private Date startTime;
    private Date endTime;
    private Integer failCount;

    /**
     * 转换类
     */
    public static final Convert convert = Mappers.getMapper(Convert.class);

    @Mapper(uses = CustomConverter.class)
    @DecoratedWith(AbstractDecoder.class)
    public interface Convert {

        IotWorkOrderPO toPO(IotWorkOrderBO bo);

        IotWorkOrderBO formPO(IotWorkOrderPO po);

        IotWorkOrderVO toVO(IotWorkOrderBO bo);

        IotWorkOrderBO formVO(IotWorkOrderVO vo);
    }

    /**
     * 抽象转换器
     */
    public static abstract class AbstractDecoder implements Convert {
        private final Convert convert;

        public AbstractDecoder(Convert convert) {
            this.convert = convert;
        }
    }
}